using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Fulan.OutlookSyn.Objects;
using Fulan.OutlookSyn.Helper;
using Fulan.OutlookSyn.Properties;

namespace Fulan.OutlookSyn
{
    public partial class FrmMain : Form
    {
        public FrmMain()
        {
            InitializeComponent();

            SettingInfo setting = SettingInfoHelper.GetSettingInfo();
            this.timer.Interval = setting.RefreshTime * (int.Parse(Resources.Minuite));
            this.timer.Start();
            NotifyIconControl.timer = this.timer;
            NotifyIconControl.notifyIcon = this.notifyIcon;
        }

        private void notifyIcon_DoubleClick(object sender, EventArgs e)
        {
            NotifyIconControl.NotifyIconctrl.MainForm = this;
            this.Show();
            this.WindowState = FormWindowState.Normal;
            this.Focus();
        }

        private void FrmMain_Deactivate(object sender, EventArgs e)
        {
            if(this.WindowState==FormWindowState.Minimized)
            {
                this.Visible = false;
            }
        }

        private void mnuSetting_Click(object sender, EventArgs e)
        {
            FrmSetting frm = new FrmSetting();
            frm.ShowDialog();
            frm.Dispose();
        }

        private void mnuExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void timer_Tick(object sender, EventArgs e)
        {
            MainSynInfo syn = new MainSynInfo();
            syn.Start();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MainSynInfo syn = new MainSynInfo();
            syn.Start();
        }
    }
}